/*
 * Created on 29/06/2006
 *
 */
package ar.com.cubika.trainees.view;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ar.com.cubika.trainees.bean.transportes.Chofer;
import ar.com.cubika.trainees.bean.transportes.Empresa;
import ar.com.cubika.trainees.bean.transportes.vehiculos.Camionazo;
import ar.com.cubika.trainees.bean.transportes.vehiculos.Camioncito;
import ar.com.cubika.trainees.bean.transportes.vehiculos.Camioneta;
import ar.com.cubika.trainees.bean.transportes.vehiculos.Combi;
import ar.com.cubika.trainees.dao.VehiculoDAO;

public class AceptarVehiculoServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		String patente = request.getParameter("patente");
		String tipo = request.getParameter("tipo");
		
		VehiculoDAO vd = VehiculoDAO.getInstance();

		Empresa empresa = Empresa.getInstance();

		if (tipo.equals("camionazo")) {
			Camionazo c = new Camionazo(patente);
			vd.insertVehiculo(c);
			empresa.addVehiculo(c);
		
		}
		if (tipo.equals("camioneta")) {
			Camioneta c = new Camioneta(patente);
			vd.insertVehiculo(c);
			empresa.addVehiculo(c);
		}

		if (tipo.equals("camioncito")) {
			Camioncito c = new Camioncito(patente);
			vd.insertVehiculo(c);
			empresa.addVehiculo(c);
		}

		if (tipo.equals("combi")) {
			Combi c = new Combi(patente);
			vd.insertVehiculo(c);
			empresa.addVehiculo(c);
		}

		request.getRequestDispatcher("/viewEmpresa").forward(request, response);

	}

}